package gson;


import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import bean.User;

public class GsonObject {
 public static void main(String[] args) {
	 
   	   User user=new User();
   	   user.setName("Ben");
   	   user.setAge(22);
   	   user.setBirthday("1996-06-26");
   	   user.setCar(null);
   	   user.setMajor(new String[]{"JAVAEE","Android"});
   	   user.setHas_house(false);
//			System.out.println(new JSONObject(user).toString());
      //
   	        GsonBuilder gsonBuilder=new GsonBuilder();
   	        gsonBuilder.setPrettyPrinting();
   	        
			Gson gson=gsonBuilder.create();
			System.out.println(gson.toJson(user));
      }

}
